<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改采购订单执行')" />
    <th:block th:include="include :: datetimepicker-css" />
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function() {
            // 获取订单列表（以order为接口前缀）
            $.ajax({
                url: "/ob/order/listAll",  // 订单列表接口，使用order前缀
                type: "GET",
                success: function(data) {
                    var orderSelect = $("#orderId");
                    $.each(data, function(index, order) {
                        orderSelect.append('<option value="' + order.orderId + '">' + order.orderId + '</option>');
                    });
                },
                error: function(error) {
                    console.error('获取订单列表失败:', error);
                }
            });

        });
    </script>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-execution-edit" th:object="${purchaseOrderExecution}">
            <input name="executionId" th:field="*{executionId}" type="hidden">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">订单编号：</label>
                    <div class="col-sm-8">
                        <select id="orderId" name="orderId"></select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">实际到货数量：</label>
                    <div class="col-sm-8">
                        <input name="actualQuantity" th:field="*{actualQuantity}" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">执行时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="executionTime" th:value="${#dates.format(purchaseOrderExecution.executionTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">操作人：</label>
                    <div class="col-sm-8">
                        <input name="operator" th:field="*{operator}" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "ob/execution";
        $("#form-execution-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-execution-edit').serialize());
            }
        }

        $("input[name='executionTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>